/**
 * Created by Administrator on 2017/5/2.
 */
/**
 * Created by Administrator on 2017/4/30.
 */
//时间
function time(){
    var date = new Date();//获取当前日期
    var week;//获取星期
    switch (date.getDay()){
        case 1: week="Monday"; break;
        case 2: week="Tuesday"; break;
        case 3: week="Wednesday"; break;
        case 4: week="Thursday"; break;
        case 5: week="Friday"; break;
        case 6: week="Saturday"; break;
        default:week="Sunday"; break;
    }
    var month;  //获取月份
    switch (date.getMonth()+1){
        case 1: month="January"; break;
        case 2: month="february "; break;
        case 3: month="March "; break;
        case 4: month="April "; break;
        case 5: month="May "; break;
        case 6: month="June "; break;
        case 7: month="July "; break;
        case 8: month="August"; break;
        case 9: month="September"; break;
        case 10: month="October "; break;
        case 11: month="November"; break;
        case 12: month="December"; break;
    }
    var year = date.getFullYear();//获取年份
    var day = date.getDate();//获取当天的日
    if(day<10)
        day= "0"+day;
    var hours =date.getHours();//获取小时
    if(hours<10)
        hours= "0"+hours;
    var minutes =date.getMinutes();//获取分
    if(minutes<10)
        minutes= "0"+minutes;
    var day =day+" "+month+","+week;
    var H=hours;
    var M=minutes;
    document.getElementById("YY").innerHTML= year;
    document.getElementById("day").innerHTML= day;
    document.getElementById("H").innerHTML= H;
    document.getElementById("M").innerHTML= M;
}
//设置1秒调用一次show_cur_times函数
setInterval("time()",100);

define('resetPWD', ['avalon', 'text!../../package/resetPWD/resetPWD.html',
        'css!../../package/resetPWD/resetPWD.css',
        '../../lib/tip/tip.js'],
    function (avalon, html, css) {
        var vm = avalon.define({
            $id: "resetPWD",
            ready: function (i) {
                index.html=html

                avalon.scan()
            },

            loginZhuce:function () {
                goto("#!/Login/0")
            },



            UID: cache.go('UID'),
            Account:cache.go('Account'),
            PWD:"", //新密码
            xPWD:"",//重复密码
            Code:"",//原密码
            resetPWD:function () {
                if (vm.Code.length<6){
                    tip.on("原密码为空或者小于6位",0,1000)
                }else{
                    if (vm.PWD.length<6){
                        tip.on("密码为空或者小于6位",0,1000)
                    }else {
                        if (vm.xPWD=vm.PWD){
                            require(['../../obj/User'],function (obj) {
                                obj.resetPWD(vm.UID,vm.PWD,vm.Code,vm.Account,function (res) {
                                    tip.on(res)
                                },function (err) {
                                    tip.on(err)
                                })
                            })
                        }
                        else {
                            tip.on("两次密码不一致",0,1000)
                        }
                    }

                }

            },
            xqmm:function () {
              goto("#!/Login/0")
            }


        })
        return window[vm.$id]=vm
    })